<?php

namespace App\ApiCall\Wx\Pay;

use Illuminate\Support\Facades\Storage;

class WxPayExecute
{
    private $client;

    public function __construct($configName)
    {
        $pathConfig = Storage::path('certificates/'.$configName);
        $wxConfig = config('openapi.wx.wx_pay.'.$configName);
        $this->client = WxPayClient::getInstance($wxConfig,[
            'api_shop_cert_url' => $pathConfig.DIRECTORY_SEPARATOR.$wxConfig['wx_cert'],
            'api_client_key_url' => $pathConfig.DIRECTORY_SEPARATOR.'apiclient_key.pem',
        ],'https://api.mch.weixin.qq.com');
    }


    public function jsApi($data){
        return [
            'prepay_id' => 'wx201410272009395522657a690389285100'
        ];
    }


    public function native($data){
        $this->client->setRequestType('POST');
        $res = $this->client->execute('/v3/pay/transactions/native',$data);
        dd($res);
    }
}
